home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 27 / CU Amiga Magazine's Super CD-ROM 27 (1998)(EMAP Images)(GB)[!][issue 1998-10].iso / CUCD / Programming / THXPlayLib / src / misc.asm < prev    next >
Encoding:
Assembly Source File  |  1998-06-16  |  4.9 KB  |  198 lines

  1. ;****** thxplay.library/thxPlaytime ******************************************
  2. ;
  3. ;   NAME
  4. ;       thxPlaytime -- get current playtime of song.
  5. ;
  6. ;   SYNOPSIS
  7. ;       seconds [, ticks] = thxPlaytime()
  8. ;       D0         D1
  9. ;
  10. ;       ULONG thxPlaytime(void);
  11. ;
  12. ;       seconds, ticks := thxPlaytime()
  13. ;
  14. ;   FUNCTION
  15. ;       Gets the current playtime into the play of a currently playing song.
  16. ;
  17. ;   RESULT
  18. ;       seconds - the number of seconds elapsed since the start of the song.
  19. ;       ticks   - the above, in internal clock ticks instead
  20. ;
  21. ;  BUGS
  22. ;       Will wrap at 65536 seconds (18 hours).
  23. ;
  24. ;  NOTE
  25. ;       Most C compilers will be unable to get the second result, ticks. Too
  26. ;       bad. It's not that important.
  27. ;
  28. ;****************************************************************************
  29. ;
  30. ;
  31.     cnop    0,4
  32. thxPlaytime
  33.     move.l    d2,-(sp)
  34.     move.l    THX+thxBSS_P(pc),d0
  35.     beq.s    .exit
  36.     move.l    d0,a0
  37.     move.l    thx_pPlayingTime(a0),d1        ; d1 = numticks
  38.     move.l    d1,d0
  39.     moveq    #0,d2
  40.     move.w    thx_pMultiSpeed(a0),d2
  41.     addq.w    #1,d2
  42.     mulu.w    #50,d2                ; d2 = ticks per sec
  43.     divu    d2,d0                ; d0 = numticks / ticks per sec
  44.     ext.l    d0
  45. .exit    move.l    (sp)+,d2
  46.     rts
  47.  
  48.  
  49.  
  50.  
  51. ;****** thxplay.library/thxSyncByte ******************************************
  52. ;
  53. ;   NAME
  54. ;       thxSyncByte -- get sync byte value.
  55. ;
  56. ;   SYNOPSIS
  57. ;       syncvalue = thxSyncByte()
  58. ;       D0-0:7
  59. ;
  60. ;       ULONG thxSyncByte(void);
  61. ;
  62. ;       syncvalue := thxSyncByte()
  63. ;
  64. ;   FUNCTION
  65. ;       Gets the current setting of the 'external timing' byte, which can be
  66. ;       set  to any byte value at any moment in time during play of the song
  67. ;       BY  the  song  itself,  using  the '8' command  in the tracker. This
  68. ;       function  is  here to allow you to mark specific events in the music
  69. ;       with   the  '8'  command  and  a  value,  then  wait  until  calling
  70. ;       thxSyncByte()  returns that value. The returned value doesn't change
  71. ;       until another '8' command in the song changes it.
  72. ;
  73. ;   NOTE
  74. ;       Be  very  careful  not  to  busy-wait on a new value if there is the
  75. ;       possibility the song is paused or not playing.
  76. ;
  77. ;   RESULT
  78. ;       syncvalue - current value of the sync byte.
  79. ;
  80. ;****************************************************************************
  81. ;
  82. ;
  83.     cnop    0,4
  84. thxSyncByte
  85.     move.l    THX+thxBSS_P(pc),d0
  86.     beq.s    .exit
  87.     move.l    d0,a0
  88.     moveq    #0,d0
  89.     move.b    (a0),d0    ; thx_pExternalTiming(a0),d0
  90. .exit    rts
  91.  
  92.  
  93.  
  94.  
  95. ;****** thxplay.library/thxSongEnded ******************************************
  96. ;
  97. ;       thxSongEnded -- detect if song has ended.
  98. ;
  99. ;   SYNOPSIS
  100. ;       songended = thxSongEnded()
  101. ;       D0
  102. ;
  103. ;       BOOL thxSongEnded(void);
  104. ;
  105. ;       songended := thxSongEnded()
  106. ;
  107. ;   FUNCTION
  108. ;       Returns  nonzero  value if the player has detected the end of a song
  109. ;       and is now looping.
  110. ;
  111. ;   NOTE
  112. ;       The detection of songend is crap (sorry Dexter :^)
  113. ;
  114. ;   RESULT
  115. ;       songended - nonzero if song is now looping, zero otherwise.
  116. ;
  117. ;   SEE ALSO
  118. ;       thxSignalEnd()
  119. ;
  120. ;****************************************************************************
  121. ;
  122. ;
  123.     cnop    0,4
  124. thxSongEnded
  125.     move.l    THX+thxBSS_P(pc),d0
  126.     beq.s    .exit
  127.     move.l    d0,a0
  128.     moveq    #0,d0
  129.     move.b    thx_pSongEnd(a0),d0
  130.     beq.s    .exit
  131.     moveq    #-1,d0
  132. .exit    rts
  133.  
  134.  
  135.  
  136.  
  137. ;****** thxplay.library/thxSignalEnd ******************************************
  138. ;
  139. ;   NAME
  140. ;       thxSignalEnd -- Signal() when song ends.
  141. ;
  142. ;   SYNOPSIS
  143. ;       thxSignalEnd(task, signalset)
  144. ;                    A0    D0
  145. ;
  146. ;       void thxSignalEnd(struct Task *, ULONG);
  147. ;
  148. ;       thxSignalEnd(task, signalset)
  149. ;
  150. ;   FUNCTION
  151. ;       Asks  THX  to send the signalset to the specified task when the song
  152. ;       ends.  If songend occurs and the signal is sent, it will not be sent
  153. ;       again  unless  you  call thxSignalEnd() again to reload the trigger.
  154. ;       The signal will also be cancelled if you call thxStop() directly, or
  155. ;       indirectly through thxSetSong() or thxFree().
  156. ;
  157. ;   NOTE
  158. ;       The detection of songend is crap (sorry Dexter :^)
  159. ;
  160. ;   INPUTS
  161. ;       task       - pointer  to  a  task  or  process structure, simply use
  162. ;                    FindTask(NIL) to send to yourself.
  163. ;       signalset  - a 32bit set of signals, to be sent to task when songend
  164. ;                    occurs.
  165. ;
  166. ;   EXAMPLE
  167. ;       thxSignalEnd(FindTask(NIL), SIGBREAKF_CTRL_C) will send you a CTRL-C
  168. ;       when the song ends.
  169. ;
  170. ;   SEE ALSO
  171. ;       thxSongEnded(), exec.library/Signal()
  172. ;
  173. ;****************************************************************************
  174. ;
  175. ;
  176.     cnop    0,4
  177. thxSignalEnd
  178.     move.b    mod_OK(pc),d1
  179.     beq.s    .nosong
  180.     lea    task(pc),a1
  181.  
  182.     ifd    STACKARGS
  183.     move.l    8(sp),(a1)+    ; store task
  184.     move.l    4(sp),(a1)+    ; store signalset
  185.     else
  186.     move.l    a0,(a1)+    ; store task
  187.     move.l    d0,(a1)+    ; store signalset
  188.     endc
  189.     st.w    (a1)        ; set trigger
  190. .nosong    rts
  191.  
  192.  
  193. ; VARIABLES
  194. ; these are for thxSignalEnd(), and are implemented in interrupt.asm
  195. task    dc.l    0    ; APTR the task to signal
  196. signals    dc.l    0    ; ULONG signalset to send
  197. dosig    dc.w    0    ; BOOL we have yet to signal
  198.